package cn.yh.ysyx.service.serviceImpl;

import cn.yh.ysyx.mapper.RoleMapper;
import cn.yh.ysyx.model.acl.Role;
import cn.yh.ysyx.service.RoleService;
import cn.yh.ysyx.vo.acl.RoleQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>  implements RoleService {
    //分页获取角色列表
    @Override
    public IPage<Role> selectPage(Page<Role> pageParam, RoleQueryVo roleQueryVo) {
        //获取查询条件
        String roleName = roleQueryVo.getRoleName();
        //构建查询条件
        LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper();
        if(!StringUtils.isEmpty(roleName)){
            wrapper.like(Role::getRoleName,roleName);
        }
        //执行分页查询
        return baseMapper.selectPage(pageParam,wrapper);
    }
}
